package org.example.objevent.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Component
public class EventBroker {

    @Autowired
    private FallbackActor fallbackActor;

    private ConcurrentHashMap<String, EventActor> actorMap = new ConcurrentHashMap<>();

    public EventActor getActor(Event event){
        return actorMap.getOrDefault(event.getDest(), fallbackActor);

    }

    public void register(EventActor actor) {
        actorMap.put(actor.getWatchEvent(), actor);

    }

}
